import Vue from 'vue'
import Router from 'vue-router'
import Home from './views/Home.vue'

Vue.use(Router)

const router= new Router({
  routes: [
    // 引导页面
    {
      path: '/',
      name: 'guide',
      component: ()=> import('./views/guide.vue'),
      meta: {
        title: '引导',
        keepAlive: false
      }
    },
    // 乐销商城
    {
      path: '/mall',
      name: 'mall',
      component: () => import('./views/mall.vue'),
      meta: {
        title: '乐销商城',
        keepAlive: false
      }
    },
    // 立刻赚钱
    {
      path: '/makeMoney',
      name: 'makeMoney',
      component: () => import('./views/makeMoney.vue'),
      meta: {
        title: '立刻赚钱',
        keepAlive: false
      }
    },
    // 发现
    {
      path: '/found',
      name: 'found',
      component: () => import('./views/found.vue'),
      meta: {
        title: '发现',
        keepAlive: false
      }
    },
    // 游乐园
    {
      path: '/gamePark',
      name: 'gamePark',
      component: () => import('./views/gamePark.vue'),
      meta: {
        title: '游乐园',
        keepAlive: false
      }
    },
    // 我的
    {
      path: '/my',
      name: 'my',
      component: () => import('./views/my.vue'),
      meta: {
        title: '我的',
        keepAlive: false
      }
    },
    // 分类
    {
      path: '/category/:column',
      name: 'category',
      component: () => import('./views/mall/category.vue'),
      meta: {
        title: '分类',
        keepAlive: false
      }
    },
    {
      path: '/home',
      name: 'home',
      component: Home,
      meta: {
        title: 'home',
        keepAlive: false
      }
    },
    {
      path: '/about',
      name: 'about',
      // route level code-splitting
      // this generates a separate chunk (about.[hash].js) for this route
      // which is lazy-loaded when the route is visited.
      component: () => import(/* webpackChunkName: "about" */ './views/About.vue'),
      meta: {
        title: 'about',
        keepAlive: false
      }
    }
  ]
})

export default router
router.beforeEach(({meta}, from, next) => {
  document.title = meta.title
  next()
})